
// 发送请求
function send(url, params, cb, method = 'post') {
    return wx.request({
        url: url,
        data: params,
        header: {
            'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
        },
        method: method,
        success(res) {
            return cb(res.data)
        },
        fail(e) {
            return cb({code: -1, msg: '请求失败', data: {}})
        }
    })
}

// 发送日志
function sendLog(url, params, cb) {
    return wx.request({
        url: url,
        data: params,
        header: {
            'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
        },
        method: 'post',
        success(res) {
            return cb(res.data)
        },
        fail(e) {
            return cb({code: -1, msg: '请求失败'})
        }
    })
}

export default {
    send,
    sendLog
}
